﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using LabMS.BLL;
using ExtendBLL;
using System.Collections.Generic;

namespace LabMS.Web.LabPersonnel
{
    public partial class AddPositionLog : Base.BasePage
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {
            strPagePrivilege.Add("GWRZGL");
            strPageUserType.Add("mana");
            strPageUserType.Add("teacher");
            PLogTime.Attributes.Add("onclick", "c.showMoreDay = false;c.show(this);");
            PLogTime.Attributes.Add("readOnly","-1");
            PLogTeacherName.Attributes.Add("readOnly","-1");
            PLogTeacherName.Text = UserRealName.ToString();
        }

        protected void Submit_OnClick(object sender, EventArgs e)
        {
            #region 验证
            if (string.IsNullOrEmpty(PLogTeacherName.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "教师名称不能为空!");
                return;
            }
            if (string.IsNullOrEmpty(PLogTime.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "时间不能为空!");
                return;
            }
            if (string.IsNullOrEmpty(PLogLabIntro.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "实验教学情况不能为空!");
                return;
            }
            if (string.IsNullOrEmpty(PLogEquipment.Text.Trim()))
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "仪器设备运行情况不能为空!");
                return;
            }
            #endregion

            LabMS.Model.PositionLog posLog = new LabMS.Model.PositionLog();
            LabMS.BLL.PositionLog posLogInfo = new LabMS.BLL.PositionLog();
            ExtendBLL.PositionLog positionLog = new ExtendBLL.PositionLog();

            posLog.PLog_TeacherCode = UserCode;
            posLog.PLog_TeacherName = PLogTeacherName.Text.Trim();
            posLog.PLog_Time = Convert.ToDateTime(PLogTime.Text.Trim());
            posLog.PLog_LabIntro = PLogLabIntro.Text.ToString().Trim();
            posLog.PLog_Equipment = PLogEquipment.Text.Trim();
            posLog.PLog_Other = PLogOther.Text.Trim();
            posLog.PLog_RecodeTime = DateTime.Now;

            posLogInfo.Add(posLog);
            LabMS.Common.JShelper.JSAlertAndRedirect(Page,"AddSuccess","添加成功!","AddPositionLog.aspx");
        }
    }
}
